package models;

import java.util.List;

import com.google.appengine.api.datastore.Blob;

import play.data.validation.Required;

import siena.Filter;
import siena.Index;
import siena.Query;
import siena.embed.Embedded;
import siena.embed.Embedded.Mode;

public class InformationUnit extends AbstractUnit {
	/** The activity of this unit */
	@Index("infomationrequest_index")
	@Required public InformationRequest informationRequest;
	
	public String content;
	
	public String link;
	
	@Filter("unit")
	public Query<UploadFile> files;
	
	static Query<InformationUnit> all() {
		return all(InformationUnit.class);
	}
	
	public static InformationUnit findById(Long id) {
		return all().filter("id", id).get();
	}
	
	public static List<InformationUnit> findByAuthor(User author) {
		return all().filter("author", author).fetch();
	}
	
	public static List<InformationUnit> findByInformatioRequest(InformationRequest request) {
		return all().filter("activity", request).fetch();
	}
}
